package org.rexsong.sample.petstore.controllers;

import org.rexsong.sample.petstore.exceptions.PetStoreException;
import org.rexsong.sample.petstore.models.Invoice;
import org.rexsong.sample.petstore.services.InvoiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class InvoiceController {
    private InvoiceService invoiceService;

    @Autowired
    public InvoiceController(InvoiceService invoiceService){
        this.invoiceService = invoiceService;
    }

    @RequestMapping(path= "/invoices", method = RequestMethod.GET)
    public List<Invoice> invoices() throws PetStoreException {
        return invoiceService.findAll();
    }
}